<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>编辑资料</title>
    <!-- JQuery -->
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <!-- Bootstrap核心CSS和JS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $(function () {

            /* 获取登录的用户信息 */
            $.getJSON(
                "/user/getInfo",
                {},
                function (json) {
                    if (json.statusCode !== 200) {

                    } else {
                        $("#nav_login").html(`
                        <a href="/space">
                        <span class="glyphicon glyphicon-user"></span>
                        <span id="userName">${json.data.realname}</span></a>
                        `);

                        $("#nav_register").html(`
                    <a href="/user/signOut">安全退出</a>
                    `);

                    }
                },
                "json"
            );


            $.getJSON(
                "/space/getInfo",
                {},
                function (json) {
                    if (json.statusCode !== 200) {
                        alert("获取失败！"+json.msg);
                        location.href = "../";
                        return false;
                    }
                    user = json.data;
                    $("#username").val(user.username);
                    $("#password").val(user.password);
                    $("#realname").val(user.realname);
                }
            )
        })

        /* 搜索 */
        function search() {
            let key = $("#key").val();
            location.href = "/goods/search/" + key;
        }
    </script>
</head>
<body>
<div class="container">
    <!-- 导航 -->
    <nav class="navbar navbar-default" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1"><span
                    class="sr-only">WTUShop导航栏</span><span class="icon-bar"></span><span
                    class="icon-bar"></span><span class="icon-bar"></span></button>
            <a class="navbar-brand" href="/">WTUShop</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <!-- 左边 -->
            <ul class="nav navbar-nav">
                <li><a href="/goods/search">商场</a></li>
                <li><a href="/kill/list">秒杀活动</a></li>
                <li class="active"><a href="/space/">个人中心</a></li>
                <li><a href="/admin/manage">控制台</a></li>
            </ul>
            <!-- 右边 -->
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/shopping/list">购物车</a></li>
                <li><a href="/order/list">订单查询</a></li>
                <li id="nav_login"><a href="/login"><span
                        class="glyphicon glyphicon-user"></span><span id="Theuser">请登录</span></a></li>
                <li id="nav_register"><a href="/register">注册</a></li>
                <li>&nbsp;&nbsp;</li><!-- 占位符 -->
            </ul>
        </div>

    </nav>
    <!-- 标题和搜索 -->
    <div class="row clearfix page-header">
        <div class="col-md-8 column">
            <a href="#"><h1 id="webName">编辑资料</h1></a>
        </div>

        <div class="input-group col-md-4 column " style="margin-top: 20px">
            <input type="text" class="form-control" placeholder="搜索商品" id="key">
            <span class="input-group-btn">
                <a href="javaScript:search()">
                <button id="btn_search" class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 搜索
                </button>
                    </a>
                    &nbsp;
            </span>
        </div>
    </div>

    <ul class="breadcrumb">
        <li><a href="/space">个人中心</a></li>
        <li class="active" id="pathName">编辑资料</li>
    </ul>

    <form class="form-horizontal" role="form" action="/user/doEdit" method="post">
        <div class="form-group">
            <label class="col-sm-2 control-label" for="username">
                用户名：
            </label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="username" name="username">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label" for="password">
                密码：
            </label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="password" name="password">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label" for="checkPassword">
                确认密码：
            </label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="checkPassword" name="checkPassword">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label" for="realname">
                真实姓名：
            </label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="realname" name="realname">
                <button class="btn btn-lg btn-primary btn-block" style="margin-top: 30px" type="submit">确认修改</button>
            </div>
        </div>

    </form>
</div>

</body>
</html>